from app.bot.utils.kopeechka.errors import (
    ACTIVATION_CANCELED,
    BAD_BALANCE,
    BAD_DOMAIN,
    BAD_SITE,
    BAD_TOKEN,
    NO_ACTIVATION,
    OUT_OF_STOCK,
    SYSTEM_ERROR,
    TIME_LIMIT_EXCEED,
    WAIT_LINK,
)
from app.bot.utils.logger import log


class MailboxGetEmail:
    def __init__(self, json: dict):
        self.data: dict = json
        self.status: str = self.data.get("status")
        self.id: str | None = self.data.get("id")
        self.mail: str | None = self.data.get("mail")
        self.value: str | None = self.data.get("value")
        if self.status == "ERROR":
            if self.value == "BAD_TOKEN" or self.value == "invalid token user":
                raise BAD_TOKEN(data=self.data)
            elif self.value == "BAD_SITE":
                raise BAD_SITE(data=self.data)
            elif self.value == "BAD_DOMAIN":
                raise BAD_DOMAIN(data=self.data)
            elif self.value == "BAD_BALANCE":
                raise BAD_BALANCE(data=self.data)
            elif self.value == "OUT_OF_STOCK":
                raise OUT_OF_STOCK(data=self.data)
            elif self.value == "SYSTEM_ERROR":
                raise SYSTEM_ERROR(data=self.data)
            elif self.value == "TIME_LIMIT_EXCEED":
                raise TIME_LIMIT_EXCEED(data=self.data)


class MailboxGetMessage:
    def __init__(self, json: dict):
        self.data: dict = json
        self.status: str = self.data.get("status")
        self.value: str | None = self.data.get("value")
        self.fullmessage: str | None = self.data.get("fullmessage")
        if self.status == "ERROR":
            if self.value == "BAD_TOKEN":
                raise BAD_TOKEN(data=self.data)
            elif self.value == "WAIT_LINK":
                raise WAIT_LINK(data=self.data)
            elif self.value == "NO_ACTIVATION":
                raise NO_ACTIVATION(data=self.data)
            elif self.value == "ACTIVATION_CANCELED":
                raise ACTIVATION_CANCELED(data=self.data)
